import { GUIComponent } from "../../../../../com/mui/controls/GUIComponent";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { PlayerFightStrength } from "./PlayerFightStrength";
import { ToolTipsManager } from "../../../../../com/mui/manager/ToolTipsManager";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { ProgressBase } from "../ProgressBase";
import { PlayerRuneFight } from "./PlayerRuneFight";
import { SFightAttribute } from "../../../../../Message/Public/SFightAttribute";
import { CareerUtil } from "../../common/util/CareerUtil";
import { Cache } from "../../../cache/Cache";
import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { LookupPlayerData } from "../LookupPlayerData";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
type int = number;
//class AttributeInfoPanel
    
    export  class AttributeInfoPanel extends GUIComponent
    {
        constructor()
        {
            super();
            this._attrNameArray = [Language.getString(30238), Language.getString(30016), Language.getString(30018), Language.getString(30019), Language.getString(30020), Language.getString(30021), Language.getString(30022), Language.getString(30023), Language.getString(30024)];
            this._attrValueArray = [];
            this._textFieldArray = [];
            this._attrValueTxt = [];
            this._barTxtArr = [];
            this._barArr = [];
            this.mouseEnabled = false;
            return;
        }

        public set mode(arg1: string)
        {
            this._mode = arg1;
            return;
        }

        protected /* override */ createChildren(): void
        {
            this._bg1 = ObjCreate.createBg(0, 0, 135, 45, this);
            this._bg2 = ObjCreate.createBg(0, 48, 135, 78, this);
            this._bg3 = ObjCreate.createBg(0, 129, 135, 95, this);
            this._shengmingBar = this.createProgressBars(Language.getString(30025), 0, "Shengmingtiao");
            this._mofaBar = this.createProgressBars(Language.getString(30026), 1, "Mofatiao");
            this.createAttrTextField();
            this._fightStrenght = new PlayerFightStrength();
            this._fightStrenght.y = 227;
            addChild(this._fightStrenght);
            this.runeFight();
            return;
        }

        /* internal  */createAttrTextField(): void
        {
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc1=0;
            loc4 = 0;
            while (loc4 < this._attrNameArray.length) 
            {
                loc2 = new Object /* flash.text.TextField */();
                loc3 = new Object /* flash.text.TextField */();
                loc2.x = 15;
                if (loc4 <= 3) 
                {
                    loc2.y = 17 * loc4 + 52;
                }
                else if (loc4 >= 4 && loc4 <= 8) 
                {
                    loc2.y = 17 * loc4 + 63;
                }
                if (loc4 <= 3) 
                {
                    loc3.x = 80;
                }
                else 
                {
                    loc3.x = 55;
                }
                loc3.y = loc2.y;
                loc2.height = 20;
                loc2.width = 145;
                loc2.selectable = false;
                loc2.autoSize = flash.text.TextFieldAutoSize.LEFT;
                ToolTipsManager.register(loc2, null, HTMLUtil.addColor(GameDefConfig.instance.getRoleAttrDesc(loc4), "#FFFFFF"));
                this._textFieldArray.push(loc2);
                this.addChild(loc2);
                loc3.height = 20;
                loc3.width = 50;
                loc3.selectable = false;
                ToolTipsManager.register(loc3, null, HTMLUtil.addColor(GameDefConfig.instance.getRoleAttrDesc(loc4), "#FFFFFF"));
                this._attrValueTxt.push(loc3);
                addChild(loc3);
                ++loc4;
            }
            return;
        }

        /* internal  */createProgressBars(arg1: string, arg2: int, arg3: string): ProgressBase
        {
            var loc1;
            (loc1 = ObjCreate.createTextField("", 3, 5 + arg2 * 20, 60, 20, this)).htmlText = "<font color=\'#ffff00\'>" + arg1 + "</font>";
            this._barTxtArr.push(loc1);
            var loc2;
            (loc2 = new ProgressBase()).x = loc1.x + loc1.textWidth + 5;
            loc2.y = 7 + arg2 * 20;
            loc2.progressBarClass = arg3;
            loc2.setValue(5542, 6515);
            this.addChild(loc2);
            this._barArr.push(loc2);
            return loc2;
        }

        public runeFight(arg1: int=0): void
        {
            var loc1=0;
            var loc2=0;
            var loc3=false;
            var loc4=null;
            var loc5=null;
            var loc6=0;
            var loc7=null;
            if (arg1 >= 65) 
            {
                loc1 = 52;
                loc2 = 63;
                this._bg1.height = 45;
                this._bg2.y = 48;
                this._bg2.height = 78;
                this._bg3.y = 129;
                this._bg3.height = 95;
                this._fightStrenght.y = 227;
                this._fightStrenght.resetPos(false);
                if (this._runeFight == null) 
                {
                    this._runeFight = new PlayerRuneFight();
                }
                this._runeFight.y = 285;
                addChild(this._runeFight);
                loc3 = true;
            }
            else 
            {
                loc1 = 84;
                loc2 = 100;
                this._bg1.height = 75;
                this._bg2.y = 78;
                this._bg2.height = 80;
                this._bg3.y = 161;
                this._bg3.height = 100;
                this._fightStrenght.y = 264;
                this._fightStrenght.resetPos(true);
                if (this._runeFight && this._runeFight.parent) 
                {
                    removeChild(this._runeFight);
                }
                loc3 = false;
            }
            loc6 = 0;
            while (loc6 < this._textFieldArray.length) 
            {
                loc4 = this._textFieldArray[loc6];
                loc5 = this._attrValueTxt[loc6];
                if (loc6 <= 3) 
                {
                    loc4.y = 17 * loc6 + loc1;
                    loc5.y = 17 * loc6 + loc1;
                }
                else if (loc6 >= 4 && loc6 <= 8) 
                {
                    loc4.y = 17 * loc6 + loc2;
                    loc5.y = 17 * loc6 + loc2;
                }
                ++loc6;
            }
            loc6 = 0;
            while (loc6 < this._barTxtArr.length) 
            {
                loc4 = this._barTxtArr[loc6];
                loc7 = this._barArr[loc6];
                if (loc3) 
                {
                    loc4.x = 3;
                    loc7.x = loc4.x + loc4.textWidth + 5;
                    loc4.y = 5 + loc6 * 20;
                    loc7.y = 7 + loc6 * 20;
                    loc7.setWidth(95);
                }
                else 
                {
                    loc4.x = 50;
                    loc7.x = 10;
                    loc4.y = 3 + loc6 * 32;
                    loc7.y = 21 + loc6 * 32;
                    loc7.setWidth(115);
                }
                ++loc6;
            }
            return;
        }

        public updateRuneFight(arg1: string): void
        {
            if (this._runeFight && !(arg1 == "")) 
            {
                this._runeFight.updateRuneFight(arg1);
            }
            return;
        }

        public updateAttrText(arg1: SFightAttribute, arg2: int): void
        {
            var loc3=null;
            var loc4=null;
            var loc5=null;
            var loc6=null;
            var loc1=CareerUtil.isPhysicalCareer(Cache.instance.role.careerEnabled);
            var loc2=0;
            if (this._mode != GModuleEvent.Mode_Self) 
            {
                if (this._mode != GModuleEvent.Mode_Other) 
                {
                    if (this._mode == GModuleEvent.Mode_ArenaCross) 
                    {
                        if (loc4 = LookupPlayerData.arenaCrossLookInfo.wuxing) 
                        {
                            loc2 = loc4.fightValue;
                        }
                    }
                }
                else if (loc4 = LookupPlayerData.lookupData.wuxingFightAttribute) 
                {
                    loc2 = loc4.fightValue;
                }
            }
            else if (loc3 = Cache.instance.role.wuxingInfo) 
            {
                loc2 = loc3.fightValue;
            }
            this._attrValueArray = [];
            this._attrValueArray.push(loc2);
            if (CareerUtil.isPhysicalCareer(arg2)) 
            {
                this._attrValueArray.push(arg1.physicalAttack);
                this._attrNameArray[1] = Language.getString(30016);
            }
            else 
            {
                this._attrValueArray.push(arg1.magicAttack);
                this._attrNameArray[1] = Language.getString(30017);
            }
            this._attrValueArray.push(arg1.physicalDefense);
            this._attrValueArray.push(arg1.magicDefense);
            this._attrValueArray.push(arg1.power);
            this._attrValueArray.push(arg1.agile);
            this._attrValueArray.push(arg1.habitus);
            this._attrValueArray.push(arg1.brains);
            this._attrValueArray.push(arg1.spiritual);
            var loc7=0;
            while (loc7 < this._textFieldArray.length) 
            {
                loc5 = this._textFieldArray[loc7] as Object /* flash.text.TextField */;
                loc6 = this._attrValueTxt[loc7] as Object /* flash.text.TextField */;
                if (loc7 <= 3) 
                {
                    loc5.htmlText = HTMLUtil.addColor(this._attrNameArray[loc7], "#f0ea3f");
                    loc6.htmlText = HTMLUtil.addColor(String(this._attrValueArray[loc7]), "#F1FFB1");
                }
                else 
                {
                    loc5.htmlText = HTMLUtil.addColor(this._attrNameArray[loc7], "#60e71e");
                    loc6.htmlText = HTMLUtil.addColor(String(this._attrValueArray[loc7]), "#F1FFB1");
                }
                ++loc7;
            }
            return;
        }

        public updateFightStrength(arg1: string): void
        {
            this._fightStrenght.updateFightStrength(arg1);
            return;
        }

        public updateWuXingFightInfo(): void
        {
            var loc1=0;
            var loc2=Cache.instance.role.wuxingInfo;
            if (loc2) 
            {
                loc1 = loc2.fightValue;
            }
            (this._attrValueTxt[0] as Object /* flash.text.TextField */).htmlText = HTMLUtil.addColor(String(loc1), "#F1FFB1");
            return;
        }

        /* internal */ /* var */_attrNameArray: Array<any>;

        /* internal */ /* var */_attrValueArray: Array<any>;

        /* internal */ /* var */_textFieldArray: Array<any>;

        public /* var */_shengmingBar: ProgressBase;

        public /* var */_mofaBar: ProgressBase;

        /* internal */ /* var */_fightStrenght: PlayerFightStrength;

        /* internal */ /* var */_attrValueTxt: Array<any>;

        /* internal */ /* var */_runeFight: PlayerRuneFight;

        /* internal */ /* var */_barTxtArr: Array<any>;

        /* internal */ /* var */_barArr: Array<any>;

        /* internal */ /* var */_mode: string="自己";

        /* internal */ /* var */_bg1: ScaleBitmap;

        /* internal */ /* var */_bg2: ScaleBitmap;

        /* internal */ /* var */_bg3: ScaleBitmap;
    }
